//package com.homedo.async.mysql.support.dao;
//
//import com.google.common.collect.Lists;
//import com.jgshun.vertx.webflux.demo.model.User;
//import com.jgshun.vertx.webflux.demo.support.dao.dml.DMLEnum;
//import com.jgshun.vertx.webflux.demo.support.dao.meta.EntityMetaData;
//import com.jgshun.vertx.webflux.demo.support.dao.prepare.PrepareObject2Sql;
//import com.jgshun.vertx.webflux.demo.support.dao.prepare.PrepareObjectType;
//import com.jgshun.vertx.webflux.demo.support.dao.prepare.PrepareRecords2Sql;
//import com.jgshun.vertx.webflux.demo.support.dao.prepare.util.CollectRecordColumnValUtil;
//import io.vertx.sqlclient.Tuple;
//import com.homedo.plainly.logger.Logger;
//import com.homedo.plainly.logger.LoggerFactory;
//import reactor.core.publisher.Mono;
//
//import java.lang.reflect.Field;
//import java.util.*;
//import java.util.stream.Collectors;
//
///**
// * @author jgshun
// * @date 2020/1/20 5:02 PM
// */
//public class MyMapper_bak<T> {
//    private static final Logger _LOGGER = LoggerFactory.getLogger(MyMapper_bak.class);
//
//    public <T> Mono<List<T>> list(T record) {
//        EntityMetaData entityMetaData = new EntityMetaData(record.getClass());
//
////        Object[] prepareSelectSql1 = this.prepareSelectSql(record, entityMetaData, DMLEnum.SELECT);
////        System.out.println(Arrays.toString(prepareSelectSql1));
//
//        Object[] prepareSelectSql = new PrepareObject2Sql(record, entityMetaData, DMLEnum.SELECT, PrepareObjectType.ENTITY_RECORD, true).prepare();
//
//        System.out.println(Arrays.toString(prepareSelectSql));
//
//        return null;
//    }
//
//    public static void main(String[] args) {
//        MyMapper_bak myMapper = new MyMapper_bak();
//
//        User user = new User();
//        user.setId(100);
//        user.setUpdateTime(new Date());
//        user.setRealname("zhangsan");
//
//        myMapper.list(user);
//
//
//        User user1 = new User();
//        user1.setDepartment("架构部");
//
//        EntityMetaData entityMetaData = new EntityMetaData(user.getClass());
//
//        Object[] prepareSelectSql = new PrepareRecords2Sql(entityMetaData, DMLEnum.SELECT, Lists.newArrayList(user, user, user, new User(), user1), true).prepare();
//
//        System.out.println(Arrays.toString(prepareSelectSql));
//
//    }
//
//    private <T> Object[] prepareSelectSql(T record, EntityMetaData entityMetaData, DMLEnum dml) {
//        Object[] prepareSelectSql = new Object[2];
//
//        Map<Field, String> fieldColumNameMapping = entityMetaData.getFieldColumNameMapping();
//
//        StringBuilder sqlBud = new StringBuilder();
//        Tuple conditionVals = Tuple.tuple();
//
//        sqlBud.append(" select ")
//                .append(fieldColumNameMapping.values().stream().collect(Collectors.joining(",")))
//                .append(" from ")
//                .append(entityMetaData.getTableName());
//
//        Map<String, Object> columnValMap = CollectRecordColumnValUtil.collect(record, entityMetaData, true);
//
//        if (!columnValMap.isEmpty()) {
////            sqlBud.append(" where ")
////                    .append(columnValMap.entrySet().stream().map(e -> {
////                        return " " + e.getKey() + " = " + e.getValue() + " ";
////                    }).collect(Collectors.toList()).stream().collect(Collectors.joining(" AND ")));
//
//            Set<String> columnNameSet = columnValMap.keySet();
//            conditionVals = Tuple.tuple(columnNameSet.stream().map(e -> {
//                return columnValMap.get(e);
//            }).collect(Collectors.toList()));
//
//            sqlBud.append(" where ")
//                    .append(columnNameSet.stream().map(e -> {
//                        return new StringBuilder().append(" ").append(e).append(" = ? ").toString();
//                    }).collect(Collectors.toList()).stream().collect(Collectors.joining(" AND ")));
//        }
//
//        prepareSelectSql[0] = sqlBud.toString();
//        prepareSelectSql[1] = conditionVals;
//
//        return prepareSelectSql;
//    }
//
//}
